<?php
    header('Access-Control-Allow-Origin:*');
    header("content-type:text/html;charset=utf-8");
    // echo '<pre>';
    // print_r($_POST);
    if($_POST){
        $table_name = 'controller'.$_POST['project_id'];
        $row_type = $_POST['type'];
        $row_name = $_POST['name'];
        $row_address = $_POST['address'];
        $row_data_type = $_POST['data_type'];
        $row_value = $_POST['value'];
        $row_priority = $_POST['priority'];
        $row_room = $_POST['room'];
        $row_room_desc = $_POST['room_desc'];
        $db_con = mysqli_connect('localhost','root','');
        if($db_con){
            $result = mysqli_query($db_con,'set names utf8');
            $result = mysqli_query($db_con,'use sx_control');
            $sql = "insert into $table_name values(default ,'$row_type', '$row_name','$row_address','$row_data_type','$row_value','$row_priority','$row_room','$row_room_desc')";
            $result = mysqli_query($db_con,$sql);
            $result = mysqli_query($db_con,'select * from controller');
            while($data = mysqli_fetch_assoc($result)){
                print_r($data);
            }
            mysqli_close($db_con);
        } else {
            die ('数据库连接失败');
        }
    }
?>